import React from "react";

class InputNumber extends React.Component {
    constructor(props) {
        super(props);
    
        this.add = this.add.bind(this);
        this.div = this.div.bind(this);
    }
    state = {
        number: 0
    }
    add() {
        this.setState({number: this.state.number + 1})
    }
    div() {
        this.setState({number: this.state.number - 1})
    }
    render() {
        return (
            <div>
                <button onClick={this.div}>减</button>
                <input readOnly={true}  value={ this.state.number }/>
                <button onClick={this.add}>加</button>
            </div>
        )
    }
}

export default InputNumber